<?php

// Gestion des derniers films ajoutés
if ($this->nbMovies == 0) {
    $lastAddedBlockTitle = $this->translate('index_last_added');
    $lastAddedBlockContent = $this->translate('index_movies_none');
}
else {
    $lastAddedBlockTitle = $this->translate('index_last_added');// . " (" . $this->nbMovies . ")";
    $lastAddedBlockContent = "<table>";
    $lastAddedBlockContent .= "<tr>";
    $lastAddedBlockContent .= "<th>" . $this->translate('index_movies_name') . "</th>";
//     $lastAddedBlockContent .= "<th>" . $this->translate('index_movies_my_rating') . "</th>";
//     $lastAddedBlockContent .= "<th>" . $this->translate('index_movies_rating_avg') . "</th>";
//     $lastAddedBlockContent .= "<th>" . $this->translate('index_movies_rating_nb') . "</th>";
    $lastAddedBlockContent .= "<th>" . $this->translate('index_movies_added') . "</th>";
    $lastAddedBlockContent .= "</tr>";

    foreach ($this->lastMoviesAdded as $movie) {
        $lastAddedBlockContent .= "<tr>";
        $lastAddedBlockContent .= "<td>" . $movie['name'] . "</td>";
//         $lastAddedBlockContent .= "<td>" . $movie['myRating'] . "</td>";
//         $lastAddedBlockContent .= "<td>" . $movie['ratingAvg'] . "</td>";
//         $lastAddedBlockContent .= "<td>" . $movie['ratingNb'] . "</td>";
        $lastAddedBlockContent .= "<td>" . $movie['added'] . "</td>";
        $lastAddedBlockContent .= "</tr>";
    }
// 	$lastAddedBlockContent .= "<tr><td>...</td><td>...</td><td>...</td><td>...</td></tr>";
    $lastAddedBlockContent .= "</table>";
//     $lastAddedBlockContent .= "<br/>";
//     $lastAddedBlockContent .= '<a class="button" href="#">' . $this->translate('index_movies_see_all') . '</a>';
//     $lastAddedBlockContent .= '<a class="button" href="#">' . $this->translate('index_movies_search') . '</a>';
}


// Gestion des films les mieux notés
$bestRatingBlockTitle = $this->translate('index_best_rated'); // "Films les mieux notés";
$bestRatingBlockContent = "";

$bestRatingBlockContent = "<table>";
$bestRatingBlockContent .= "<tr>";
$bestRatingBlockContent .= "<th>" . $this->translate('index_movies_name') . "</th>";
$bestRatingBlockContent .= "<th>" . $this->translate('index_movies_rating_avg') . "</th>";
$bestRatingBlockContent .= "<th>" . $this->translate('index_movies_rating_nb') . "</th>";
$bestRatingBlockContent .= "</tr>";
foreach ($this->bestRatedMovies as $movie) {
    $bestRatingBlockContent .= "<tr>";
    $bestRatingBlockContent .= "<td>" . $movie['name'] . "</td>";
    $bestRatingBlockContent .= "<td>" . $movie['ratingAvg'] . "</td>";
    $bestRatingBlockContent .= "<td>" . $movie['ratingNb'] . "</td>";
    $bestRatingBlockContent .= "</tr>";
}
$bestRatingBlockContent .= "</table>";




// Gestion des utilisateurs
$nbFriends = count($this->friends);
$friendBlockContent = '<a class="button" onclick="showAddFriendBox()" href="#">' . $this->translate('index_friends_add') . '</a>';
$friendBlockContent .= "<br/>";
if ($nbFriends == 0) {
    $friendBlockTitle = $this->translate('index_friends_title');
    $friendBlockContent .= $this->translate('index_friends_none');
}
else {
    $friendBlockTitle = $this->translate('index_friends_title') . " ($nbFriends)";
    $friendBlockContent .= "<table>
        <tr>
            <th>" . $this->translate('index_user_name') . "</th>
            <th>" . $this->translate('index_user_movies') . "</th>
            <th>" . $this->translate('index_user_delete') . "</th>
        </tr>";
//     foreach ($this->friends as $userVO) {
//         $friendBlockContent .= "<tr>
//             <td>" . $userVO->publicName . "</td>
//             <td>(nb) - lien</td>
//             <td><img class='button' src='/mediaglobe/images/icons/delete.png'/></td>
//         </tr>";
//     }
    $friendBlockContent .= "</table>";
}
$friendBlockContent .= $this->translate('index_movie_requests_to_none');
$friendBlockContent .= '<br/>';
$friendBlockContent .= $this->translate('index_movie_requests_from_none');

?>

<!--
<div style='width:45%;background-color:white;display:inline-block;vertical-align:top'>
    <h2>Bienvenue sur Mediaglobe</h2>
    <h2>Vous</h2>
    <h3>Dernière visite</h3>
    <h3>Nombre de films ajoutés</h3>
    <h3>Nombre d'amis</h3>
    <h2>Les autres utilisateurs</h2>
    <h3>Nombre d'utilisateurs</h3>
    <h3>Nombre de films ajoutés</h3>
</div>
-->

<!-- Message de bienvenue -->
<?php
if ($this->connection === false) :
?>
<div id='block-container' style='padding-bottom:0px;'>
    <div class='block' style='min-height:0px;margin-bottom:0px;'>
        <div class='block-header'><?php echo 'Bienvenue !'; ?></div>
        <div class='block-body' style='min-height:0px;'><?php echo 'Veuillez-vous connecter pour profiter des services que vous propose Mediaglobe.'; ?></div>
    </div>
</div>
<?php
endif;
?>


<div id='block-container'>

    <!-- Derniers films ajoutés -->
    <div class='block'>
        <div class='block-header'><?php echo $lastAddedBlockTitle; ?></div>
        <div class='block-body'><?php echo $lastAddedBlockContent; ?></div>
    </div>

    <!-- Films les mieux notés -->
    <div class='block'>
        <div class='block-header'><?php echo $bestRatingBlockTitle; ?></div>
        <div class='block-body'><?php echo $bestRatingBlockContent; ?></div>
    </div>

    <!-- Liste d'amis
    <div class='block'>
        <div class='block-header'>< ?php echo $friendBlockTitle; ?></div>
        <div class='block-body'>< ?php echo $friendBlockContent; ?></div>
    </div>-->

</div>

<!-- Liste des demandes de partage de film
<div class='block'>
    <div class='block-header'>< ?php echo $this->translate('index_movie_requests_title'); ?></div>
    <div class='block-body'>
        < ?php echo $this->translate('index_movie_requests_to_none'); ?>
        <br/>
        < ?php echo $this->translate('index_movie_requests_from_none'); ?>
    </div>
</div>-->
